<?php
namespace Admin\Controller;
use Common\Controller\CommonController;
class IndexController extends CommonController {
    public function index(){

    }

    //添加留言-显示表单
     public function add(){
     	$this->display();
    }
     //添加留言-处理表单
     public function doadd(){
        $title = trim(I('post.title'));
        $content = trim(I('post.content'));

        if(empty($title)){
            $this->error('标题不能为空');
        }
            $model = D('Message');
        #get_client_ip($num); 0:得到127.0.0.1类型 1：123456789字符串
        #添加纪录
        $id = $model->add(
                    [
                    'title'=> $title,'content'=>$content,'ip'=>get_client_ip(0),'ip2'=>get_client_ip(1)
                    ]
            );
        $this->success("添加成功 id为 {$id}");
    }
}